package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HouseSellre;
import com.ruoyi.system.service.IHouseSellreService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中介人员Controller
 * 
 * @author ruoyi
 * @date 2024-04-26
 */
@Controller
@RequestMapping("/system/sellre")
public class HouseSellreController extends BaseController
{
    private String prefix = "system/sellre";

    @Autowired
    private IHouseSellreService houseSellreService;

    @RequiresPermissions("system:sellre:view")
    @GetMapping()
    public String sellre()
    {
        return prefix + "/sellre";
    }

    /**
     * 查询中介人员列表
     */
    @RequiresPermissions("system:sellre:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HouseSellre houseSellre)
    {
        startPage();
        List<HouseSellre> list = houseSellreService.selectHouseSellreList(houseSellre);
        return getDataTable(list);
    }

    /**
     * 导出中介人员列表
     */
    @RequiresPermissions("system:sellre:export")
    @Log(title = "中介人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HouseSellre houseSellre)
    {
        List<HouseSellre> list = houseSellreService.selectHouseSellreList(houseSellre);
        ExcelUtil<HouseSellre> util = new ExcelUtil<HouseSellre>(HouseSellre.class);
        return util.exportExcel(list, "中介人员数据");
    }

    /**
     * 新增中介人员
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存中介人员
     */
    @RequiresPermissions("system:sellre:add")
    @Log(title = "中介人员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HouseSellre houseSellre)
    {
        return toAjax(houseSellreService.insertHouseSellre(houseSellre));
    }

    /**
     * 修改中介人员
     */
    @RequiresPermissions("system:sellre:edit")
    @GetMapping("/edit/{sellerId}")
    public String edit(@PathVariable("sellerId") Long sellerId, ModelMap mmap)
    {
        HouseSellre houseSellre = houseSellreService.selectHouseSellreBySellerId(sellerId);
        mmap.put("houseSellre", houseSellre);
        return prefix + "/edit";
    }

    /**
     * 修改保存中介人员
     */
    @RequiresPermissions("system:sellre:edit")
    @Log(title = "中介人员", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HouseSellre houseSellre)
    {
        return toAjax(houseSellreService.updateHouseSellre(houseSellre));
    }

    /**
     * 删除中介人员
     */
    @RequiresPermissions("system:sellre:remove")
    @Log(title = "中介人员", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(houseSellreService.deleteHouseSellreBySellerIds(ids));
    }
}
